package com.desiy.service.impl;

import com.desiy.dao.BooksDao;
import com.desiy.pojo.entity.Books;
import com.desiy.service.BooksService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

@Service
public class BooksServiceImpl implements BooksService {

    @Resource
    private BooksDao booksDao;

    @Override
    public Books queryById(Integer id) {
        return this.booksDao.queryById(id);
    }

    @Override
    public Collection<Books> queryAll() {
        List<Books> books = booksDao.queryAll();
        return books;
    }

    @Override
    public int insert(Books books) {
        return this.booksDao.insert(books);
    }
    @Override
    public Books update(Books books) {
        booksDao.update(books);
        return this.queryById(books.getBookid());
    }
    @Override
    public boolean deleteById(Integer id) {
        booksDao.deleteById(id);
        return true;
    }

    @Override
    public Books queryByName(String name) {
        return this.booksDao.queryByName(name);
    }
}